﻿/*****************************************************************//**
 *
 * @file   FITKAbaqusAdaptorLoad.h
 * @brief  Abaqus Load 适配器 用于读取INP过程中的Load解析。
 * @author fulipeng (flipengqd@yeah.net)
 * @date   2024-03-26
 *
 *********************************************************************/
#ifndef __FITKABAQUSADAPTORLOAD__H__
#define __FITKABAQUSADAPTORLOAD__H__

#include "FITKAbaqusAbstractAdaptor.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITKAbaqusGetInterfaceTool.h"

 //前置声明
ForwardDeclarNS(AbaqusData, FITKDataCase)
ForwardDeclarNS(Interface, FITKAbaAbstractLoad)
ForwardDeclarNS(Interface, FITKAbaLoadConcentratedForce)
ForwardDeclarNS(Interface, FITKAbaLoadPressure)
ForwardDeclarNS(Interface, FITKAbaLoadMoment)
ForwardDeclarNS(Interface, FITKAbaLoadBodyForce)
ForwardDeclarNS(Interface, FITKAbaLoadGravity)
ForwardDeclarNS(Interface, FITKModelSet)
ForwardDeclarNS(Interface, FITKMeshSurface)

namespace IO
{
    /**
     * @brief Abaqus Load 读写适配器
     * @author fulipeng (fulipengqd@yeah.net)
     * @date 2024-03-26
     */
    class FITKAbaqusIOINPAPI FITKAbaqusAdaptorLoad : public FITKAbaqusAbstractAdaptor
    {
    public:
        explicit FITKAbaqusAdaptorLoad() = default;
        ~FITKAbaqusAdaptorLoad() = default;

        /**
         * @brief 获取适配器数据类型名
         * @return 适配器数据类型名
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        QString getAdaptorClass() override;

        /**
         * @brief 设置load取消激活分析步
         * @param[i] word 关键字
         * @param[i] stepId 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-24
         */
        void setLoadDeactiveStepR(QString word, int stepId);

        /**
         * @brief 设置算例数据对象
         * @param caseData
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        void setCaseData(AbaqusData::FITKDataCase* caseData);

        /**
         * @brief 设置关键字所在的行数据
         * @param line 关键字所在的行数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        void setLineKeywords(QString line);

        /**
         * @brief 设置写出的数据
         * @param op 关键字op数据
         * @param stepId 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        void setWriterData(QString op, int stepId);

        /**
         * @brief 适配器读取 CFORCE
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        bool adaptR() override;

        /**
         * @brief 适配器写出
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        bool adaptW() override;
        /**
         * @brief 数据是否为空
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-24
         */
        bool isValueEmpty();

    private:
        /**
         * @brief 读取集中力
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-01
         */
        bool cLoadConcentratedForceR();
        /**
         * @brief 读取弯矩
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        bool cLoadMomentR();
        /**
         * @brief 读取表面压强载荷
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        bool dsLoadPressureR();
        /**
         * @brief 读取体力载荷
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-09
         */
        bool dLoadBodyForceR();
        /**
         * @brief 读取重力载荷
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-09
         */
        bool dLoadGravityR();
        /**
         * @brief 写入集中力
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-01
         */
        bool cLoadConcentratedForceW();
        /**
         * @brief 写入弯矩
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        bool cLoadMomentW();
        /**
         * @brief 写入表面压强载荷
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        bool dsLoadPressureW();
        /**
         * @brief 写入体力载荷
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-09
         */
        bool dLoadBodyForceW();
        /**
         * @brief 写入重力载荷
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-09
         */
        bool dLoadGravityW();
        /**
         * @brief  获取集合解析场数据
         * @param[i] setData 几何数据
         * @param[i] type 几何类型
         * @param[o] nameList 
         * @param[o] resultList 
         * @return 状态 true成功， false失败
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-11-26
         */
        bool getAnalyticalDataBySetData(Interface::FITKModelSet* setData, int type, QStringList& nameList, QList<double>& resultList);
        /**
         * @brief  获取表面析场数据
         * @param[i] surfData 表面数据
         * @param[i] type 几何类型
         * @param[o] polygonStringTypeList 
         * @param[o] nameList 
         * @param[o] resultList 
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2024-11-26
         */
        bool getAnalyticalDataBySurfData(Interface::FITKMeshSurface* surfData, int type, QStringList& polygonStringTypeList, QStringList& nameList, QList<double>& resultList);

    private:

        /**
         * @brief 算例数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-03-26
         */
        AbaqusData::FITKDataCase* _caseData{};
        /**
         * @brief 关键字的行
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-07
         */
        QString _keywordsLine{};
        /**
         * @brief op数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        QString _op{};
        /**
         * @brief 分析步id
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-15
         */
        int _stepId{ 0 };
        /**
         * @brief 获取接口 工具类
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-04-25
         */
        FITKAbaqusGetInterfaceTool _tool;
        /**
         * @brief 记录数据是否为空
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-05-24
         */
        bool _isValueEmp{ false };
    };
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaAbstractLoad, FITKAbaqusAdaptorLoad, 1)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaLoadConcentratedForce, FITKAbaqusAdaptorLoad, 2)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaLoadMoment, FITKAbaqusAdaptorLoad, 3)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaLoadPressure, FITKAbaqusAdaptorLoad, 4)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaLoadBodyForce, FITKAbaqusAdaptorLoad, 5)
    Register2FITKIOAdaptorFactory(INP, Interface::FITKAbaLoadGravity, FITKAbaqusAdaptorLoad, 6)
}

#endif